{extend name='public/base'} {block name='content'}

<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        {$item['item1']}
        <small>{$item['item2']}</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="#">
                <i class="fa fa-dashboard"></i> {$item['item1']}</a>
        </li>
        <li class="active">{$item['item2']}</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="panel panel-default">
        <ul class="layui-nav layui-bg-green">
                <li class="layui-nav-item layui-this"><a href="{:url('merchant/register/index')}">新增登记</a></li>
                <li class="layui-nav-item"><a href="{:url('merchant/register/record')}">登记记录</a></li>
        </ul>
    </div>

    <form action="index" class="layui-form layui-form-pane" id="mainForm" method="post">
            <div class="layui-form-item">
              <label class="layui-form-label">卡号</label>
              <div class="layui-input-block">
                    <input name="card_id" id="card_id" class="layui-input" autocomplete="off" placeholder="请输入卡号">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">绑定手机</label>
              <div class="layui-input-block">
                    <input name="phone_id" id="phone_id" class="layui-input" autocomplete="off" placeholder="绑定手机">
              </div>
            </div>
            
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                  <input type="text" name="name" id="name" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                  <input type="text"  name="phone" id="phone" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">年龄</label>
                <div class="layui-input-inline">
                  <input type="text"  name="age" id="age" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">出身年月</label>
                <div class="layui-input-inline">
                  <input type="text"  name="birth" id="birth" autocomplete="off" class="layui-input">
                </div>
              </div>
              
            </div>


            <div class="layui-form-item" pane="">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男" checked="">
                    <input type="radio" name="sex" value="2" title="女">
                    <input type="radio" name="sex" value="0" title="不详" disabled="">
                </div>
            </div>


            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">身高</label>
                <div class="layui-input-inline">
                  <input type="text"  name="height" id="height" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">体重</label>
                <div class="layui-input-inline">
                  <input type="text"  name="weight" id="weight" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">血型</label>
                <div class="layui-input-inline">
                  <input type="text"  name="blood" id="blood" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">身份证</label>
              <div class="layui-input-block">
                    <input name="idcard" id="idcard" class="layui-input" autocomplete="off">
              </div>
            </div>    
            
            
            <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">微信</label>
                <div class="layui-input-inline">
                  <input type="text"  name="wechat" id="wechat" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text"  name="email" id="email" autocomplete="off" class="layui-input">
                </div>
              </div>
            </div>

            <div class="layui-form-item layui-form-text">
              <div class="layui-input-block">
                <textarea placeholder="请输入地址" name="address" id="address" class="layui-textarea"></textarea>
              </div>
            </div>
           
            <div class="layui-form-item" pane="">
              <label class="layui-form-label">状态</label>
              <div class="layui-input-block">
                    <input type="checkbox" checked="" name="status" id="status" lay-skin="switch" lay-filter="switchTest" lay-text="开|关">
              </div>
            </div>
            
            
            <div class="layui-form-item">
              <button class="layui-btn" type="submit">确定登记</button>
            </div>
          </form>
    <!-- /.row -->
</section>
<!-- /.content -->


{/block} {block name='script'}
<script>
    //增加数据
    $(function () {
        //表格功能
        $('#example1').DataTable({
            'paging': true,
            'lengthChange': true,
            'searching': true,
            'ordering': false,
            'info': true,
            'autoWidth': true
        });


        //JQuery里面的方法,ajaxSubmit来提交表单
        var options = {
            type: 'post', //post提交
            //url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType: "json", //json格式
            data: {}, //如果需要提交附加参数，视情况添加
            clearForm: false, //成功提交后，清除所有表单元素的值
            resetForm: false, //成功提交后，重置所有表单元素的值
            cache: false,
            async: false, //同步返回
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 2,
                        offset: 'm',
                        time: 1000
                    });
                } else {
                    layer.msg(data.msg, {
                        icon: 1,
                        offset: 'm',
                        time: 1500
                    }, function () {
                        location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        layui.use('form', function(){
            var form = layui.form;
            $('#mainForm').ajaxForm(options).submit(function(data){});
        });

    })
    //新增用户的模态框数据清除
    $("#addModal,#editModal").on('hide.bs.modal', function () {
        $('#addReset').click();
    });
    //加载缓冲动画
    $("#addModal,#editModal").on('show.bs.modal', function () {
        layer.closeAll();
    });


    //删除用户
    function delete_register(id) {
        layer.confirm('确定删除吗？', function (index) {
            $.ajax({
                    url: '{:url("merchant/Register/delete_register")}',
                    type: 'get',
                    dataType: 'json',
                    data: {
                        id: id
                    },
                })
                .done(function (data) {
                    //回调提示
                    if (data.code == 0) {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1000
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1500
                        }, function () {
                            location.reload();
                        });
                    }
                })
        })
    }
</script>
{/block}